package com.restkeeper.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.restkeeper.dto.DyDevicesDto;
import com.restkeeper.entity.DyDevices;
import com.restkeeper.service.DyDevicesService;
import com.restkeeper.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/dyDevices")
public class DyDevicesController {

    @Autowired
    private DyDevicesService dyDevicesService;

    /**
     * 分页查询
     */
    @GetMapping("/page")
    public Result page(@RequestParam(defaultValue = "1") long current,
                       @RequestParam(defaultValue = "10") long size) {
        Page<DyDevices> page = new Page<>(current, size);
        return Result.ok(dyDevicesService.page(page, new QueryWrapper<>()));
    }

//    /**
//     * 分页查询
//     */
//    @GetMapping("/startDeviceInfo")
//    public Result startDeviceInfo() {
//        return Result.ok();
//    }

    /**
     * 获取次数详情
     */
    @PostMapping("/deviceInfo")
    public Result startDeviceInfo(@RequestBody DyDevicesDto dto) {
        return dyDevicesService.deviceInfo(dto);
    }

    /**
     * 启动设备
     */
    @PostMapping("/startDevice")
    public Result startDevice(@RequestBody DyDevicesDto dto) {
        return dyDevicesService.startDevice(dto);
    }


}